//
//  MYGReportsTableViewCell.swift
//  MYDoctor
//
//  Created by Mo on 2024/3/7.
//

import UIKit

class MYGReportsTableViewCell: UITableViewCell {
    var titleLab:UILabel!
    var comLab:UILabel!
    var timeLab:UILabel!
    var contentImageV:UIImageView!
    var shareNumLab:UILabel!
    var seeNumLab:UILabel!
    var model = MYGArticleModel()
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        contentImageV = UIImageView()
        contentImageV.contentMode = .scaleAspectFill
        contentImageV.layer.masksToBounds = true
        contentImageV.layer.cornerRadius = SCALEWIDTH(5)
//        contentImageV.backgroundColor = .red
        contentView.addSubview(contentImageV)
        contentImageV.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(SCALEWIDTH(-12))
            make.top.equalToSuperview().offset(SCALEWIDTH(15))
            make.size.equalTo(CGSize(width: SCALEWIDTH(100), height: SCALEWIDTH(80)))
        }
        
        titleLab = UILabel()
        titleLab.textColor = RGBA(r: 51, g: 51, b: 51, a: 1)
        titleLab.font = UIFont.systemFont(ofSize: 15, weight: .medium)
        titleLab.text = "klfjsjfkjfklsjkfljslkfjklsfjklsjf"
        titleLab.numberOfLines = 2
        self.contentView.addSubview(titleLab)
        titleLab.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(SCALEWIDTH(16))
            make.left.equalToSuperview().offset(SCALEWIDTH(12))
            make.right.equalTo(contentImageV.snp.left).offset(SCALEWIDTH(-12))
            make.height.equalTo(SCALEWIDTH(39))
        }
        
        comLab = UILabel()
        comLab.textColor = RGBA(r: 255, g: 59, b: 48, a: 1)
        comLab.font = UIFont.systemFont(ofSize: 13, weight: .regular)
        comLab.text = "单位名称"
        self.contentView.addSubview(comLab)
        comLab.snp.makeConstraints { make in
            make.top.equalTo(titleLab.snp.bottom).offset(SCALEWIDTH(5.5))
            make.left.equalToSuperview().offset(SCALEWIDTH(12))
            make.right.equalTo(contentImageV.snp.left).offset(SCALEWIDTH(-12))
            make.height.equalTo(SCALEWIDTH(18.5))
        }
        
        timeLab = UILabel()
        timeLab.textColor = RGBA(r: 128, g: 128, b: 128, a: 1)
        timeLab.font = UIFont.systemFont(ofSize: 12, weight: .regular)
        timeLab.text = "2020-20-20"
        self.contentView.addSubview(timeLab)
        timeLab.snp.makeConstraints { make in
            make.top.equalTo(comLab.snp.bottom).offset(SCALEWIDTH(5))
            make.left.equalToSuperview().offset(SCALEWIDTH(12))
            make.height.equalTo(SCALEWIDTH(16.5))
        }
        
        let shareImageV = UIImageView()
        shareImageV.image = UIImage(named: "MYG_myPage_share")
        contentView.addSubview(shareImageV)
        shareImageV.snp.makeConstraints { make in
            make.left.equalTo(timeLab.snp.right).offset(SCALEWIDTH(14))
            make.centerY.equalTo(timeLab)
            make.size.equalTo(CGSize(width: SCALEWIDTH(10.5), height: SCALEWIDTH(8.5)))
        }
        
        shareNumLab = UILabel()
        shareNumLab.textColor = RGBA(r: 158, g: 163, b: 173, a: 1)
        shareNumLab.font = UIFont.systemFont(ofSize: 12, weight: .regular)
        shareNumLab.text = "10"
        self.contentView.addSubview(shareNumLab)
        shareNumLab.snp.makeConstraints { make in
            make.centerY.equalTo(timeLab)
            make.left.equalTo(shareImageV.snp.right).offset(SCALEWIDTH(3))
            make.height.equalTo(SCALEWIDTH(16.5))
        }
        
        let eyeImageV = UIImageView()
        eyeImageV.image = UIImage(named: "MYG_myPage_eye")
        contentView.addSubview(eyeImageV)
        eyeImageV.snp.makeConstraints { make in
            make.left.equalTo(shareNumLab.snp.right).offset(SCALEWIDTH(10))
            make.centerY.equalTo(timeLab)
            make.size.equalTo(CGSize(width: SCALEWIDTH(12.5), height: SCALEWIDTH(8)))
        }
        
        seeNumLab = UILabel()
        seeNumLab.textColor = RGBA(r: 158, g: 163, b: 173, a: 1)
        seeNumLab.font = UIFont.systemFont(ofSize: 12, weight: .regular)
        seeNumLab.text = "10"
        self.contentView.addSubview(seeNumLab)
        seeNumLab.snp.makeConstraints { make in
            make.centerY.equalTo(timeLab)
            make.left.equalTo(eyeImageV.snp.right).offset(SCALEWIDTH(3))
            make.height.equalTo(SCALEWIDTH(16.5))
        }
        
        let lineView = UIView()
        lineView.backgroundColor = RGBA(r: 238, g: 238, b: 238, a: 1)
        contentView.addSubview(lineView)
        lineView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(12))
            make.right.equalToSuperview().offset(SCALEWIDTH(-12))
            make.bottom.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(0.5))
        }
    }
    
    func bindData(_ data:MYGArticleModel) {
        self.model = data
//        self.contentImageV.sd_setImage(with: URL(string: data.fm_img))
//        self.titleLab.text = self.model.title
//        self.comLab.text = self.model.from
//        self.timeLab.text = self.model.updated_at
//        self.shareNumLab.text = "\(self.model.is_share)"
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
